<template>
	<view class="page">
		<view>
			<view style="margin: auto;width: 100%;padding-top: 30rpx;text-align: center;">
				<image :src="data_mes.img" mode="widthFix" style="width: 500rpx;margin: auto;"></image>
			</view>
			<view style="margin: auto;width: 100%;margin-top: 30rpx;text-align: center;position: relative;">
				<image src="../../../static/img/104.jpg" mode="widthFix" style="width: 700rpx;margin: auto;"></image>
				<view style="position: absolute;top: 120rpx;bottom: 0;left: 0;right: 0;">
					<view style="font-size: 42rpx;font-weight: bold;">{{data_mes.name}}</view>
					<view class="crad-tip">
						<view class="tip-overall">
							源自馆藏
						</view>

						<view class="tip-half">
							<text class="tip-half-neo">限量</text>
							<text class="tip-half-two">{{data_mes.num}}份</text>
						</view>
						<view class="tip-on">
							{{data_mes.select_type==1? '新春专题':'普通专题'}}
						</view>
					</view>
					<view>
					</view>
				</view>
			</view>
		</view>

		<view
			style="width: 95%;background-color: #1b1d1c;margin: auto;margin-top: 20rpx;display: flex;align-items: center;height: 150rpx;align-items: center;border-radius: 15rpx;">
			<view style="margin-left: 30rpx;">
				<image src="../../../static/img/105.png" mode="widthFix" style="width: 100rpx;border-radius: 50%;">
				</image>
			</view>
			<view style="margin-left: 30rpx;">
				<view style="font-size: 24rpx;opacity: 0.5;">创作者</view>
				<view style="font-size: 28rpx;opacity: 0.8;">{{data_mes.author}}</view>
			</view>
		</view>


		<view style="width: 95%;margin: auto;background-color: #1b1d1c;border-radius: 15rpx;margin-top: 30rpx;">
			<view style="padding: 50rpx 0;padding-left: 30rpx;font-size: 38rpx;font-weight: bold;">作品故事</view>
			<view style="width: 90%;border-radius: 30rpx;margin: auto;">
				<view class="u-content">
					<u-parse :content="data_mes.content"></u-parse>
				</view>
			</view>
			<view style="width: 90%;margin: auto;display: flex;justify-content: space-between;padding: 30rpx 0;">
				<view style="font-size: 24rpx;opacity: 0.5;">发行方</view>
				<view style="font-size: 26rpx;opacity: 0.8;">{{data_mes.issuer}}</view>
			</view>
		</view>


		<view style="width: 95%;margin: auto;background-color: #1b1d1c;border-radius: 15rpx;margin-top: 30rpx;">
			<view style="width: 90%;margin: auto;padding: 30rpx 0;font-size: 38rpx;font-weight: bold;">购买须知</view>
			<view style="width: 90%;margin: auto;padding-bottom: 20rpx;opacity: 0.5;font-size: 24rpx;">
				数字藏品为虚拟数字商品，而非实物，仅限实名认证为年满14周岁的中国大陆用户购买。数字藏品的版权由发行方或原创者拥有，除另行取得版权拥有者书面同意外，用户不得将数字藏品用于任何商业用途。本商品一经售出，不支持退换。本商品源文件不支持本地下载。请勿对数字藏品进行炒作、场外交易、欺诈，或以任何其他非法方式进行使用。
			</view>
		</view>

		<view style="margin-top: 30rpx;text-align: center;opacity: 0.5;padding-bottom: 160rpx;">
			XXX提供技术支持
		</view>


		<view style="position: fixed;bottom: 0;display: flex;justify-content: space-between;
		background-color: #0c0e0d;width: 100%;align-items: center;height: 100rpx;">
			<view style="font-size: 42rpx;font-weight: bold;margin-left: 50rpx;">￥{{data_mes.price}}</view>
			<view style="margin-right: 50rpx;">
				<button type="default" style="color: #ffffff;border-radius: 30rpx;background-color: #a16715;height: 60rpx;
				line-height: 60rpx;padding: 0 40rpx;" @click="sub_nav">立即购买</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data_mes: {},
			}
		},
		onLoad(e) {
			this.getshop_mes(e.id)
		},
		methods: {
			getshop_mes(e) {
				let that = this
				this.$base.request(this.serverPath.Nftproduct_info, 'POST', {
					id: e
				}, false).then(function(data) {
					if (data.code == 200) {
						that.data_mes = data.data
						console.log(that.data_mes)
					} else {
						console.log('接口请求失败')
					}
				})
			},
			sub_nav() {
				// 检查用户是否登录
				let token = uni.getStorageSync('token')
				console.log(token)
				if (token == '') {
					// 进行登录
					return
				}
				// 发起订单
				let timestamp = new Date().getTime()
				let that = this
				this.$base.request(this.serverPath.Nftproduct_add, 'POST', {
					order_no: timestamp,
					username: '123',
					productid: that.data_mes.id,
					productname: that.data_mes.name,
					payprice: that.data_mes.price,
					status: 0
				}, false).then(function(data) {
					if (data.code == 200) {
						// 请求支付接口
						that.winxi_pay(data.data.order_no)
					} else {
						console.log('接口请求失败')
					}
				})
				// uni.navigateTo({
				// 	url: '../indent_details/indent_details'
				// })
			},
			winxi_pay(e) {
				// console.log(e)
				let that = this
				this.$base.request(this.serverPath.payment, 'POST', {
					out_trade_no: e,
					openid: 'otwLV5LmBWwDPOm0seFsYSqAoh_c',
					type: 'wx_miniapp',
					body: '1212',
					total_fee: '1'
				}, false).then(function(data) {
					console.log(data)
					if(data.code == 200){
						uni.requestPayment({
						    provider: 'wxpay',
						    timeStamp: data.data.timeStamp,
						    nonceStr: data.data.nonceStr,
						    package: data.data.package,
						    signType: data.data.signType,
						    paySign: data.data.paySign,
						    success: function (res) {
						        console.log('success:' + JSON.stringify(res));
						    },
						    fail: function (err) {
						        console.log('fail:' + JSON.stringify(err));
						    }
						});
					}else{
						console.log('接口请求失败')
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.u-content {
		padding: 24rpx;
	}

	.page {
		width: 100%;
		height: auto;
		background-color: #0c0e0d;
		position: relative;
		color: #FFFFFF;
		margin: 0;
	}

	.crad-tip {
		display: flex;
		text-align: center;
		margin-top: 20rpx;
		justify-content: center;
	}

	.tip-overall {
		height: 40rpx;
		background-color: #f3e0bc;
		color: #2B2C2E;
		font-size: 22rpx;
		font-weight: 600;
		line-height: 40rpx;
		padding: 0rpx 10rpx;
		border-radius: 5rpx;
		margin-right: 10rpx;
	}

	.tip-half {
		height: 40rpx;
		background-color: #f3e0bc;
		font-size: 22rpx;
		line-height: 40rpx;
		border-radius: 5rpx;

	}

	.tip-half-neo {
		background-color: #f3e0bc;
		height: 40rpx;
		color: #2B2C2E;
		font-size: 22rpx;
		font-weight: 600;
		line-height: 40rpx;
		padding: 0rpx 10rpx;


	}

	.tip-on {
		margin-left: 10rpx;
		background-color: #4b4b4b;
		color: #dcd8bd;
		font-size: 22rpx;
		line-height: 40rpx;
		height: 40rpx;
		padding: 0rpx 10rpx;
		border-radius: 5rpx;
	}

	.tip-half-two {
		background-color: #4b4b4b;
		color: #dcd8bd;
		font-size: 22rpx;
		line-height: 40rpx;
		height: 40rpx;
		padding: 6rpx 10rpx;
	}
</style>
